﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Blog.Models;
using System.ComponentModel.Composition;

namespace Blog.Controllers
{
    [Export(typeof(IController)), ExportMetadata("Name", "Comment")]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class CommentController : Controller
    {
        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create(Comment commentToCreate)
        {
            Context.Instance.CreateComment(commentToCreate.PostId, commentToCreate);
            return RedirectToAction("View", "Post", new { Id = commentToCreate.PostId });
        }
    }
}
